package com.btl.boot.core.dto;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 节点值
 *
 * @param <K>
 * @param <V>
 */
@Data
public class TreeNode<K, V> implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 节点id
     */
    private K id;
    /**
     * 节点名称
     */
    private V name;
    /**
     * 父节点id
     */
    private K parentId;

    /**
     * 节点排序
     */
    private Integer sort;
    /**
     * 拓展数据
     */
    private Map<String, Object> extend;
    /**
     * 子节点
     */
    private List<TreeNode<K, V>> children;

    public TreeNode(K id, V name, K parentId) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.sort = 0;
    }

    public TreeNode(K id, V name, K parentId, Map<String, Object> extend) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.extend = extend;
        this.sort = 0;
    }
    public TreeNode(K id, V name, K parentId, Integer sort, Map<String, Object> extend) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.extend = extend;
        this.sort = sort;
    }
}
